<%-- 
    Document   : addEstimate5b
    Created on : Dec 16, 2013, 5:20:48 AM
    Author     : toint-lifetek
--%>

<%@page import="java.util.List"%>
<%@page import="com.myapp.bo.WantEsBO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<jsp:include page="/jsp/pages/header.jsp" />
<script>
$(function() {
        $( "#datepicker" ).datepicker();
});
</script>
<html>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <tile></tile>
    <body>
<html:form action="/AddEstimate5bAction.do" acceptCharset="UTF-8">
    <br/>
    <div class="fieldset">
        <div class="legend">
            ĐÁNH GIÁ NHU CẦU GIAI ĐOẠN TÁI THIẾT, PHỤC HỒI SAU THIÊN TAI
        </div><%--
        <div>
            <table style="width: 100%;">
                <tr>
                    <td class="label">
                        Ngày đánh giá
                    </td>
                    <td class="row">
                        <input type="text" name="estamteDate" id="datepicker" />
                    </td>
                </tr>
            </table>
        </div>
        <br/>--%>
        <table class="tb-border" style="width: 100%;">
            <tr>
                <td class="label-stt">
                    TT
                </td>
                <td class="label">
                    Mã
                </td>
                <td class="label">
                    Nhu cầu
                </td>
                <td class="label">
                    Đơn vị
                </td>
                <td class="label">
                    Số lượng
                </td>
                <td class="label">
                    Kích cỡ
                </td>
                <td class="label">
                    Thông số kỹ thuật
                </td>
                <td class="label">
                    Số người được hưởng
                </td>
                <td class="label-tr-tb" style="margin: 0px; padding: 0px;">
                    <table class="tb-border" style="padding: 0px; margin: 0px;">
                        <tr>
                            <td colspan="3" class="label" style="text-align: center;">
                                Thành tiền
                            </td>
                        </tr>
                        <tr>
                            <td class="label-tr-td">
                                Nội lực
                            </td>
                            <td class="label-tr-td">
                                Nhà nước
                            </td>
                            <td class="label-tr-td">
                                Nguồn khác
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <%
                request.setCharacterEncoding("UTF-8");
                response.setContentType("charset=UTF-8");
                response.setCharacterEncoding("UTF-8");

                List<WantEsBO> lstWant = (List<WantEsBO>) request.getAttribute("lstWant");                                                                                                                                                                                                                    
                String[] str = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "V", "X", "Y", "Z", "W"};
                int instr = 0;
                int auId = 0;
                
                for (int i = 0; i < lstWant.size(); i++) {
                    WantEsBO want = lstWant.get(i);
                    if (want.getParentId() == 0) {
            %>
                <tr>
                    <td class="label-stt"><%= str[instr] %><input type="hidden" name="arrWantId" value="<%= want.getWantId() %>" id="arrWantId_<%= auId %>" /></td>
                    <td class="label"><%= want.getCode() == null ? "" : want.getCode() %></td>
                    <td class="label"><%= want.getName() %></td>
                    <td class="label"><input type="text" name="mapUnit(<%= want.getWantId().toString() %>)" id="mapUnit_<%= auId %>" size="10" /></td>
                    <td class="label"><input type="text" onkeydown="return isDecimalNumberKey(event);" name="mapQuantity(<%= want.getWantId().toString() %>)" id="mapQuantity_<%= auId %>" size="10" /></td>
                    <td class="label"><input type="text" name="mapSize(<%= want.getWantId().toString() %>)" id="mapSize_<%= auId %>" size="10" /></td>
                    <td class="label"><input type="text" name="mapSpecifications(<%= want.getWantId().toString() %>)" id="mapSpecifications_<%= auId %>" size="10" /></td>
                    <td class="label"><input type="text" onkeydown="return isNumberKey(event);" name="mapPersonBenfit(<%= want.getWantId().toString() %>)" id="mapPersonBenfit_<%= auId %>" size="10" /></td>
                    <td class="label-tr-tb" style="margin: 0px; padding: 0px;">
                        <table class="tb-border" style="padding: 0px; margin: 0px;">
                            <tr>
                                <td class="label-tr-td"><input onkeydown="return isDecimalNumberKey(event);" type="text" name="mapInternalForce(<%= want.getWantId().toString() %>)" id="mapInternalForce_<%= auId %>" size="10" /></td>
                                <td class="label-tr-td"><input onkeydown="return isDecimalNumberKey(event);" type="text" name="mapStage(<%= want.getWantId().toString() %>)" id="mapStage_<%= auId %>" size="10" /></td>
                                <td class="label-tr-td"><input onkeydown="return isDecimalNumberKey(event);" type="text" name="mapOther(<%= want.getWantId().toString() %>)" id="mapOther_<%= auId %>" size="10" /></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            <% 
                    instr ++;
                    int stt = 1;
                    for (int j = 0; j < lstWant.size(); j++) {
                        WantEsBO wantj = lstWant.get(j);
                        if (wantj.getParentId() != 0 && wantj.getParentId() == want.getWantId()) {
                            auId++;
            %>
                 <tr>
                    <td class="label-stt"><%= stt %><input type="hidden" name="arrWantId" value="<%= wantj.getWantId() %>" id="arrWantId_<%= auId %>" /></td>
                    <td class="label"><%= wantj.getCode() == null ? "" : wantj.getCode() %></td>
                    <td class="label"><%= wantj.getName() %></td>
                    <td class="label"><input type="text" name="mapUnit(<%= wantj.getWantId().toString() %>)" id="mapUnit_<%= auId %>" size="10" /></td>
                    <td class="label"><input type="text" onkeydown="return isDecimalNumberKey(event);" name="mapQuantity(<%= wantj.getWantId().toString() %>)" id="mapQuantity_<%= auId %>" size="10" /></td>
                    <td class="label"><input type="text" name="mapSize(<%= wantj.getWantId().toString() %>)" id="mapSize_<%= auId %>" size="10" /></td>
                    <td class="label"><input type="text" name="mapSpecifications(<%= wantj.getWantId().toString() %>)" id="mapSpecifications_<%= auId %>" size="10" /></td>
                    <td class="label"><input type="text" onkeydown="return isNumberKey(event);" name="mapPersonBenfit(<%= wantj.getWantId().toString() %>)" id="mapPersonBenfit_<%= auId %>" size="10" /></td>
                    <td class="label-tr-tb" style="margin: 0px; padding: 0px;">
                        <table class="tb-border" style="padding: 0px; margin: 0px;">
                            <tr>
                                <td class="label-tr-td"><input onkeydown="return isDecimalNumberKey(event);" type="text" name="mapInternalForce(<%= wantj.getWantId().toString() %>)" id="mapInternalForce_<%= auId %>" size="10" /></td>
                                <td class="label-tr-td"><input onkeydown="return isDecimalNumberKey(event);" type="text" name="mapStage(<%= wantj.getWantId().toString() %>)" id="mapStage_<%= auId %>" size="10" /></td>
                                <td class="label-tr-td"><input onkeydown="return isDecimalNumberKey(event);" type="text" name="mapOther(<%= wantj.getWantId().toString() %>)" id="mapOther_<%= auId %>" size="10" /></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            <%
                            stt++;
                            }
                        }
                    auId++;
                    }
                } 
            %>
        </table>
        <br/>
        <div style="text-align: center;">
            <button class="stylish" onclick="return true;" type="submit">
                <span>Ghi lại</span>
            </button>
        </div>
    </div>
</html:form>
    </body>
</html>
